﻿using Sunny.UI;

namespace Gobang.Client.View.FrmPage
{
    public partial class MainPage : UIPage
    {
        public readonly LeftPage _leftPage;
        public readonly RightPage _rightPage;
        public readonly CenterPage _centerPage;
        public readonly FrmMain _frmMain;
        /// <summary>
        /// 点击房间委托
        /// </summary>
        public Action<TreeViewEventArgs> SelectRoom;
        public MainPage(FrmMain frmMain)
        {
            InitializeComponent();

            _frmMain = frmMain;
            _leftPage = new LeftPage(this);
            _rightPage = new RightPage(this);
            _centerPage = new CenterPage(this);


            ShowControl(_leftPage, 0, 0);
            ShowControl(_centerPage, 1, 0);
            ShowControl(_rightPage, 2, 0);
        }
        private void ShowControl(UIPage uIPage, int column, int row)
        {
            uiTableLayoutPanel1.Controls.Add(uIPage, column, row);
            uIPage.Dock = DockStyle.Fill;
            uIPage.Show();
        }

        private void MainPage_FormClosing(object sender, FormClosingEventArgs e)
        {
            _leftPage?.Dispose();
            _rightPage?.Dispose();
            _centerPage?.Dispose();
        }
    }
}
